<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="../static/css/elementui.css">
    <link rel="stylesheet" href="../static/css/style.css">
    <link rel="stylesheet" href="../static/plugins/font-awesome/css/font-awesome.min.css">
    <script type="text/javascript" src="../static/js/vue.js"></script>
    <script type="text/javascript" src="../static/js/elementui.js"></script>
    <script type="text/javascript" src="../static/js/axios.js"></script>

</head>
<body class="hold-transition">
<div id="app">
    <div class="app-container">
        <div class="box">
            <div class="filter-container">

                <!--查询条件部分  searchmap -->
                <el-form ref="form" :inline="true" label-width="80px">
                    <el-form-item label="用户名">
                    <el-input v-model="searchMap.username" placeholder="用户名"></el-input>
                </el-form-item>
                    <el-form-item label="密码">
                        <el-input v-model="searchMap.password" placeholder="密码"></el-input>
                    </el-form-item>

                    <el-form-item>
                        <el-button type="primary" @click="login()">登录</el-button>
                    </el-form-item>
                </el-form>

            </div>
        </div>
    </div>
</div>

<script type="text/javascript">
    const gatewayUrl ="http://127.0.0.1:9001";
    const brand = new Vue({
        el:"#app",
        data(){
            return{
                searchMap:{
                },
            }
        },
        methods:{
            login(){
                axios.post(gatewayUrl + "/api/login",this.searchMap).then(res=>{

                    //res 响应值  token
                    if(res.data.code==0){
                        //成功 存token 页面跳转
                        localStorage.setItem("token",res.data.data.token);
                        window.location.href="/list.html"
                    }else{
                        alert(res.data.errorMessage);
                    }
                })
            }
        }
    })
</script>
</body>
</html>